\(\int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx\) [10]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 32, antiderivative size = 107 \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-2 a^2 (i A+B) x-\frac {2 a^2 (A-i B) \log (\cos (c+d x))}{d}+\frac {a^2 (i A+B) \tan (c+d x)}{d}+\frac {A (a+i a \tan (c+d x))^2}{2 d}-\frac {i B (a+i a \tan (c+d x))^3}{3 a d} \]

[Out]

-2*a^2*(I*A+B)*x-2*a^2*(A-I*B)*ln(cos(d*x+c))/d+a^2*(I*A+B)*tan(d*x+c)/d+1/2*A*(a+I*a*tan(d*x+c))^2/d-1/3*I*B*
(a+I*a*tan(d*x+c))^3/a/d

Rubi [A] (verified)

Time = 0.19 (sec) , antiderivative size = 107, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.125, Rules used = {3673, 3608, 3558, 3556} \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=\frac {a^2 (B+i A) \tan (c+d x)}{d}-\frac {2 a^2 (A-i B) \log (\cos (c+d x))}{d}-2 a^2 x (B+i A)+\frac {A (a+i a \tan (c+d x))^2}{2 d}-\frac {i B (a+i a \tan (c+d x))^3}{3 a d} \]

[In]

Int[Tan[c + d*x]*(a + I*a*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

-2*a^2*(I*A + B)*x - (2*a^2*(A - I*B)*Log[Cos[c + d*x]])/d + (a^2*(I*A + B)*Tan[c + d*x])/d + (A*(a + I*a*Tan[
c + d*x])^2)/(2*d) - ((I/3)*B*(a + I*a*Tan[c + d*x])^3)/(a*d)

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3558

Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^2, x_Symbol] :> Simp[(a^2 - b^2)*x, x] + (Dist[2*a*b, Int[Tan[c + d
*x], x], x] + Simp[b^2*(Tan[c + d*x]/d), x]) /; FreeQ[{a, b, c, d}, x]

Rule 3608

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[d*(
(a + b*Tan[e + f*x])^m/(f*m)), x] + Dist[(b*c + a*d)/b, Int[(a + b*Tan[e + f*x])^m, x], x] /; FreeQ[{a, b, c,
d, e, f, m}, x] && NeQ[b*c - a*d, 0] && EqQ[a^2 + b^2, 0] &&  !LtQ[m, 0]

Rule 3673

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(
e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[B*d*((a + b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e
 + f*x])^m*Simp[A*c - B*d + (B*c + A*d)*Tan[e + f*x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, m}, x] && NeQ[b
*c - a*d, 0] &&  !LeQ[m, -1]

Rubi steps \begin{align*} \text {integral}& = -\frac {i B (a+i a \tan (c+d x))^3}{3 a d}+\int (a+i a \tan (c+d x))^2 (-B+A \tan (c+d x)) \, dx \\ & = \frac {A (a+i a \tan (c+d x))^2}{2 d}-\frac {i B (a+i a \tan (c+d x))^3}{3 a d}-(i A+B) \int (a+i a \tan (c+d x))^2 \, dx \\ & = -2 a^2 (i A+B) x+\frac {a^2 (i A+B) \tan (c+d x)}{d}+\frac {A (a+i a \tan (c+d x))^2}{2 d}-\frac {i B (a+i a \tan (c+d x))^3}{3 a d}+\left (2 a^2 (A-i B)\right ) \int \tan (c+d x) \, dx \\ & = -2 a^2 (i A+B) x-\frac {2 a^2 (A-i B) \log (\cos (c+d x))}{d}+\frac {a^2 (i A+B) \tan (c+d x)}{d}+\frac {A (a+i a \tan (c+d x))^2}{2 d}-\frac {i B (a+i a \tan (c+d x))^3}{3 a d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.82 (sec) , antiderivative size = 82, normalized size of antiderivative = 0.77 \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=\frac {a^2 \left (3 A-2 i B+12 (A-i B) \log (i+\tan (c+d x))+12 (i A+B) \tan (c+d x)-3 (A-2 i B) \tan ^2(c+d x)-2 B \tan ^3(c+d x)\right )}{6 d} \]

[In]

Integrate[Tan[c + d*x]*(a + I*a*Tan[c + d*x])^2*(A + B*Tan[c + d*x]),x]

[Out]

(a^2*(3*A - (2*I)*B + 12*(A - I*B)*Log[I + Tan[c + d*x]] + 12*(I*A + B)*Tan[c + d*x] - 3*(A - (2*I)*B)*Tan[c +
 d*x]^2 - 2*B*Tan[c + d*x]^3))/(6*d)

Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 99, normalized size of antiderivative = 0.93

method result size
derivativedivides \(\frac {a^{2} \left (i B \left (\tan ^{2}\left (d x +c \right )\right )-\frac {B \left (\tan ^{3}\left (d x +c \right )\right )}{3}+2 i A \tan \left (d x +c \right )-\frac {A \left (\tan ^{2}\left (d x +c \right )\right )}{2}+2 B \tan \left (d x +c \right )+\frac {\left (-2 i B +2 A \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-2 i A -2 B \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(99\)
default \(\frac {a^{2} \left (i B \left (\tan ^{2}\left (d x +c \right )\right )-\frac {B \left (\tan ^{3}\left (d x +c \right )\right )}{3}+2 i A \tan \left (d x +c \right )-\frac {A \left (\tan ^{2}\left (d x +c \right )\right )}{2}+2 B \tan \left (d x +c \right )+\frac {\left (-2 i B +2 A \right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}+\left (-2 i A -2 B \right ) \arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(99\)
norman \(\left (-2 i A \,a^{2}-2 B \,a^{2}\right ) x -\frac {\left (-2 i B \,a^{2}+A \,a^{2}\right ) \left (\tan ^{2}\left (d x +c \right )\right )}{2 d}+\frac {2 \left (i A \,a^{2}+B \,a^{2}\right ) \tan \left (d x +c \right )}{d}-\frac {B \,a^{2} \left (\tan ^{3}\left (d x +c \right )\right )}{3 d}+\frac {\left (-i B \,a^{2}+A \,a^{2}\right ) \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{d}\) \(113\)
parallelrisch \(-\frac {12 i A x \,a^{2} d -6 i B \left (\tan ^{2}\left (d x +c \right )\right ) a^{2}+2 B \,a^{2} \left (\tan ^{3}\left (d x +c \right )\right )-12 i A \tan \left (d x +c \right ) a^{2}+3 A \left (\tan ^{2}\left (d x +c \right )\right ) a^{2}+6 i B \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a^{2}+12 B x \,a^{2} d -6 A \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a^{2}-12 B \tan \left (d x +c \right ) a^{2}}{6 d}\) \(127\)
parts \(\frac {\left (2 i A \,a^{2}+B \,a^{2}\right ) \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {\left (2 i B \,a^{2}-A \,a^{2}\right ) \left (\frac {\left (\tan ^{2}\left (d x +c \right )\right )}{2}-\frac {\ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}\right )}{d}+\frac {A \ln \left (1+\tan ^{2}\left (d x +c \right )\right ) a^{2}}{2 d}-\frac {B \,a^{2} \left (\frac {\left (\tan ^{3}\left (d x +c \right )\right )}{3}-\tan \left (d x +c \right )+\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(132\)
risch \(\frac {4 a^{2} B c}{d}+\frac {4 i a^{2} A c}{d}+\frac {2 i a^{2} \left (9 i A \,{\mathrm e}^{4 i \left (d x +c \right )}+15 B \,{\mathrm e}^{4 i \left (d x +c \right )}+15 i A \,{\mathrm e}^{2 i \left (d x +c \right )}+18 B \,{\mathrm e}^{2 i \left (d x +c \right )}+6 i A +7 B \right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}+\frac {2 i a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}-\frac {2 a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A}{d}\) \(146\)

[In]

int(tan(d*x+c)*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

1/d*a^2*(I*B*tan(d*x+c)^2-1/3*B*tan(d*x+c)^3+2*I*A*tan(d*x+c)-1/2*A*tan(d*x+c)^2+2*B*tan(d*x+c)+1/2*(2*A-2*I*B
)*ln(1+tan(d*x+c)^2)+(-2*B-2*I*A)*arctan(tan(d*x+c)))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 175, normalized size of antiderivative = 1.64 \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left (3 \, {\left (3 \, A - 5 i \, B\right )} a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, {\left (5 \, A - 6 i \, B\right )} a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (6 \, A - 7 i \, B\right )} a^{2} + 3 \, {\left ({\left (A - i \, B\right )} a^{2} e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, {\left (A - i \, B\right )} a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, {\left (A - i \, B\right )} a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + {\left (A - i \, B\right )} a^{2}\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right )\right )}}{3 \, {\left (d e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="fricas")

[Out]

-2/3*(3*(3*A - 5*I*B)*a^2*e^(4*I*d*x + 4*I*c) + 3*(5*A - 6*I*B)*a^2*e^(2*I*d*x + 2*I*c) + (6*A - 7*I*B)*a^2 +
3*((A - I*B)*a^2*e^(6*I*d*x + 6*I*c) + 3*(A - I*B)*a^2*e^(4*I*d*x + 4*I*c) + 3*(A - I*B)*a^2*e^(2*I*d*x + 2*I*
c) + (A - I*B)*a^2)*log(e^(2*I*d*x + 2*I*c) + 1))/(d*e^(6*I*d*x + 6*I*c) + 3*d*e^(4*I*d*x + 4*I*c) + 3*d*e^(2*
I*d*x + 2*I*c) + d)

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 178 vs. \(2 (88) = 176\).

Time = 0.35 (sec) , antiderivative size = 178, normalized size of antiderivative = 1.66 \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=- \frac {2 a^{2} \left (A - i B\right ) \log {\left (e^{2 i d x} + e^{- 2 i c} \right )}}{d} + \frac {- 12 A a^{2} + 14 i B a^{2} + \left (- 30 A a^{2} e^{2 i c} + 36 i B a^{2} e^{2 i c}\right ) e^{2 i d x} + \left (- 18 A a^{2} e^{4 i c} + 30 i B a^{2} e^{4 i c}\right ) e^{4 i d x}}{3 d e^{6 i c} e^{6 i d x} + 9 d e^{4 i c} e^{4 i d x} + 9 d e^{2 i c} e^{2 i d x} + 3 d} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))**2*(A+B*tan(d*x+c)),x)

[Out]

-2*a**2*(A - I*B)*log(exp(2*I*d*x) + exp(-2*I*c))/d + (-12*A*a**2 + 14*I*B*a**2 + (-30*A*a**2*exp(2*I*c) + 36*
I*B*a**2*exp(2*I*c))*exp(2*I*d*x) + (-18*A*a**2*exp(4*I*c) + 30*I*B*a**2*exp(4*I*c))*exp(4*I*d*x))/(3*d*exp(6*
I*c)*exp(6*I*d*x) + 9*d*exp(4*I*c)*exp(4*I*d*x) + 9*d*exp(2*I*c)*exp(2*I*d*x) + 3*d)

Maxima [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 92, normalized size of antiderivative = 0.86 \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {2 \, B a^{2} \tan \left (d x + c\right )^{3} + 3 \, {\left (A - 2 i \, B\right )} a^{2} \tan \left (d x + c\right )^{2} + 12 \, {\left (d x + c\right )} {\left (i \, A + B\right )} a^{2} - 6 \, {\left (A - i \, B\right )} a^{2} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 12 \, {\left (-i \, A - B\right )} a^{2} \tan \left (d x + c\right )}{6 \, d} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="maxima")

[Out]

-1/6*(2*B*a^2*tan(d*x + c)^3 + 3*(A - 2*I*B)*a^2*tan(d*x + c)^2 + 12*(d*x + c)*(I*A + B)*a^2 - 6*(A - I*B)*a^2
*log(tan(d*x + c)^2 + 1) + 12*(-I*A - B)*a^2*tan(d*x + c))/d

Giac [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 312 vs. \(2 (91) = 182\).

Time = 0.44 (sec) , antiderivative size = 312, normalized size of antiderivative = 2.92 \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=-\frac {2 \, {\left (3 \, A a^{2} e^{\left (6 i \, d x + 6 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 3 i \, B a^{2} e^{\left (6 i \, d x + 6 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 9 \, A a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 9 i \, B a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 9 \, A a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 9 i \, B a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 9 \, A a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} - 15 i \, B a^{2} e^{\left (4 i \, d x + 4 i \, c\right )} + 15 \, A a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} - 18 i \, B a^{2} e^{\left (2 i \, d x + 2 i \, c\right )} + 3 \, A a^{2} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) - 3 i \, B a^{2} \log \left (e^{\left (2 i \, d x + 2 i \, c\right )} + 1\right ) + 6 \, A a^{2} - 7 i \, B a^{2}\right )}}{3 \, {\left (d e^{\left (6 i \, d x + 6 i \, c\right )} + 3 \, d e^{\left (4 i \, d x + 4 i \, c\right )} + 3 \, d e^{\left (2 i \, d x + 2 i \, c\right )} + d\right )}} \]

[In]

integrate(tan(d*x+c)*(a+I*a*tan(d*x+c))^2*(A+B*tan(d*x+c)),x, algorithm="giac")

[Out]

-2/3*(3*A*a^2*e^(6*I*d*x + 6*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) - 3*I*B*a^2*e^(6*I*d*x + 6*I*c)*log(e^(2*I*d*x
+ 2*I*c) + 1) + 9*A*a^2*e^(4*I*d*x + 4*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) - 9*I*B*a^2*e^(4*I*d*x + 4*I*c)*log(e
^(2*I*d*x + 2*I*c) + 1) + 9*A*a^2*e^(2*I*d*x + 2*I*c)*log(e^(2*I*d*x + 2*I*c) + 1) - 9*I*B*a^2*e^(2*I*d*x + 2*
I*c)*log(e^(2*I*d*x + 2*I*c) + 1) + 9*A*a^2*e^(4*I*d*x + 4*I*c) - 15*I*B*a^2*e^(4*I*d*x + 4*I*c) + 15*A*a^2*e^
(2*I*d*x + 2*I*c) - 18*I*B*a^2*e^(2*I*d*x + 2*I*c) + 3*A*a^2*log(e^(2*I*d*x + 2*I*c) + 1) - 3*I*B*a^2*log(e^(2
*I*d*x + 2*I*c) + 1) + 6*A*a^2 - 7*I*B*a^2)/(d*e^(6*I*d*x + 6*I*c) + 3*d*e^(4*I*d*x + 4*I*c) + 3*d*e^(2*I*d*x
+ 2*I*c) + d)

Mupad [B] (verification not implemented)

Time = 7.65 (sec) , antiderivative size = 111, normalized size of antiderivative = 1.04 \[ \int \tan (c+d x) (a+i a \tan (c+d x))^2 (A+B \tan (c+d x)) \, dx=\frac {{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (\frac {a^2\,\left (B+A\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{2}+\frac {B\,a^2\,1{}\mathrm {i}}{2}\right )}{d}+\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (a^2\,\left (B+A\,1{}\mathrm {i}\right )+B\,a^2+A\,a^2\,1{}\mathrm {i}\right )}{d}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (2\,A\,a^2-B\,a^2\,2{}\mathrm {i}\right )}{d}-\frac {B\,a^2\,{\mathrm {tan}\left (c+d\,x\right )}^3}{3\,d} \]

[In]

int(tan(c + d*x)*(A + B*tan(c + d*x))*(a + a*tan(c + d*x)*1i)^2,x)

[Out]

(tan(c + d*x)^2*((a^2*(A*1i + B)*1i)/2 + (B*a^2*1i)/2))/d + (tan(c + d*x)*(A*a^2*1i + a^2*(A*1i + B) + B*a^2))
/d + (log(tan(c + d*x) + 1i)*(2*A*a^2 - B*a^2*2i))/d - (B*a^2*tan(c + d*x)^3)/(3*d)